<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>

<body class="gray-bg">
<div class="container-div ui-layout-center">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="staffmanager-form">
				<div class="select-list">
					<ul>
						<li>
							工号：
							<input class="idCode" type="text" name="idCode" style="width: 50px" />
						</li>
						<li>
							姓名：
							<input class="name" type="text" name="name" style="width: 50px" />
						</li>
						<li>
							邮箱：
							<input class="email" type="text" name="email" style="width: 150px"/>
						</li>
						<li>
							员工入职日期：
							<input class="joinDate" type="date" name="joinDate" style="width: 150px"/>
						</li>



						<li class="status">
							<label>在职状态：</label>
							<select type="text" class="status" id ="status"   name="status" style="width: 60px"/>
							<option value=""></option>
							<option value="在职">在职</option>
							<option value="离职">离职</option>
							</select>
						</li>

						<li>
							员工所在地域：
							<select class="region" type="text" name="region"  style="width: 60px"/>

							<option value=""></option>
							<option value="西安">西安</option>
							<option value="北京">北京</option>
							<option value="深圳">深圳</option>
							<option value="成都">成都</option>
							<option value="天津">天津</option>
							<option value="上海">上海</option>
							</select>
						</li>
						<li>
							员工技能：
							<select class="skillType" type="text" name="skillType"  style="width: 80px"/>
							<option value=""></option>
							<option value="java">java</option>
							<option value="android">android</option>
							<option value="c++">c++</option>
							<option value="python">python</option>
							</select>
						</li>
						<li>
							员工职位：
							<select class="level" type="text" name="level" style="width: 100px"/>
							<option value=""></option>
							<option value="高级工程师">高级工程师</option>
							<option value="中级工程师">中级工程师</option>
							<option value="初级工程师">初级工程师</option>
							<option value="实习工程师">实习工程师</option>
							</select>
						</li>
						<li>
							<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-success btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>

			</form>
		</div>


		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="staffmanager:list:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="staffmanager:list:remove">
				<i class="fa fa-remove"></i> 删除
			</a>
		</div>


		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('plan:config:edit')}]];
	var removeFlag = [[${@permission.hasPermi('plan:config:remove')}]];
	var prefix = ctx + "staffmanager/list";

	$(function() {
		$('body').layout({ west__size: 185 });
		load();
	});

	function load() {
		var options = {
			url: prefix + "/list",
			createUrl: prefix + "/add",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
			modalName: "员工",
			search: true,
			showExport: true,
			uniqueId: "id",
			columns: [
				{
					checkbox: true
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
					}
				},

				{
					field: 'idCode',
					title: '工号'
				},
				{
					field: 'name',
					title: '姓名'
				},
				{
					field: 'sex',
					title: '性别'
				},
				{
					field: 'phone',
					title: '电话号码'
				},
				{
					field: 'email',
					title: '邮箱'
				},
				{
					field: 'address',
					title: '住址'
				},
				{
					field: 'joinDate',
					title: '入职日期'
				},
				{
					field: 'status',
					title: '在职状态'
				},
				{
					field: 'region',
					title: '地域'
				},
				{
					field: 'skillType',
					title: '技能'
				},
				{
					field: 'level',
					title: '职位'
				}]
		};
		$.table.init(options);


		function edit(id) {
			var id = $("input[name='id']").val();
			var idCode = $("input[name='idCode']").val();
			var name = $("input[name='name']").val();
			var sex = $("input[name='sex']").val();
			var phone = $("#phone option:selected").val();
			var email = $("input[name='email']").val();
			var address = $("input[name='address']").val();
			var joinDate = $("input[name='joinDate']").val();
			var status = $("input[name='status']").val();
			var region = $("#region option:selected").val();
			var skillType = $("input[name='skillType']").val();
			var level = $("input[name='level']").val();
			$.ajax({
				cache : true,
				type : "POST",
				url : ctx + "staffmanager/list/edit",
				data : {
					"idCode": idCode,
					"name": name,
					"sex": sex,
					"phone": phone,
					"email": email,
					"address": address,
					"joinDate": joinDate,
					"status": status,
					"region": region,
					"level": level,
					"skillType": skillType
				},
				async : false,
				error : function(request) {
					$.modal.alertError("系统错误");
				},
				success : function(data) {
					$.operate.saveSuccess(data);
				}
			});
		}
	}
</script>
</body>
</html>